home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / zroutin.com / ZINPUT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-01-14  |  4.6 KB  |  268 lines

  1. procedure ZInput;
  2.  
  3. label
  4.     100;
  5.  
  6.  
  7. var
  8.     Checkchars,
  9.     ValidChars : string;
  10.  
  11.  
  12.     xx,
  13.     x,
  14.     ptr,
  15.     Currentfield : integer;
  16.  
  17.     FillChar     : string[1];
  18.  
  19.     temp,
  20.     tempr        : string;
  21.  
  22. begin
  23.  
  24.     ValidChars := '';
  25.     for x := 33 to 126 do
  26.         ValidChars := ValidChars + char(x);
  27.     ptr := 1;
  28.     CurrentField := 1;
  29.  
  30. {$IFDEF ZINFIELD}
  31.  
  32.     if Zinfield <> 0 then
  33.         begin
  34.         CurrentField := Zinfield;
  35.         Zinfield := 0;
  36.         end;
  37. {$ENDIF}
  38.  
  39.     for x := 1 to ZINumOfFields do
  40.         ZWrite ( ZICol[x], ZIRow [x], ZIData[x]);
  41.  
  42. 100:
  43.  
  44.     ZCsrSize(5,7);
  45.     gotoxy(ZICol[CurrentField] + ptr - 1, ZIRow[CurrentField]);
  46.  
  47.  
  48.     ZIKeyPressed := ReadKey;
  49.     if ZIKeyPressed = #0 then ZIKeyPressed := ZIKeyPressed + ReadKey;
  50.  
  51.  
  52.     if (ZIKeyPressed = #9) or
  53.        (ZIKeyPressed = #0 + #80) then
  54.        begin
  55.        CurrentField := CurrentField + 1;
  56.        ptr := 1;
  57.        if CurrentField > ZINumOfFields then CurrentField := 1;
  58.        goto 100;
  59.     end;
  60.  
  61.     if (ZIKeyPressed = #0 + #15) or
  62.        (ZIKeyPressed = #0 + #72) then
  63.        begin
  64.  
  65.        if CurrentField = 1 then
  66.         CurrentField := ZINumOfFields
  67.        else
  68.         CurrentField := CurrentField - 1;
  69.  
  70.        ptr := 1;
  71.  
  72.        goto 100;
  73.        end;
  74.  
  75.  
  76.     if (ZIKeyPressed = #0 + #117) then
  77.         begin
  78.         ZIData[CurrentField] := '';
  79.         ptr := 1;
  80.         gotoxy (ZICol[CurrentField], ZIRow[CurrentField]);
  81.         write (Zstring(' ', ZILen[CurrentField]));
  82.         goto 100;
  83.         end;
  84.  
  85.  
  86.     if (ZIKeyPressed = #0 + #73) then
  87.         begin
  88.         CurrentField := 1;
  89.         ptr := 1;
  90.         goto 100;
  91.         end;
  92.  
  93.     if (ZIKeyPressed = #0 + #81) then
  94.         begin
  95.         CurrentField := ZINumOfFields;
  96.         ptr := 1;
  97.         goto 100;
  98.         end;
  99.  
  100.     if (ZIKeyPressed = #13) and
  101.        (CurrentField = ZINumOfFields) then
  102.        exit;
  103.  
  104.  
  105.     if (ZIKeyPressed = #9) or
  106.        (ZIKeyPressed = #0 + #80) or
  107.        (ZIKeyPressed = #13) then
  108.        begin
  109.        CurrentField := CurrentField + 1;
  110.        ptr := 1;
  111.        if CurrentField > ZINumOfFields then CurrentField := 1;
  112.        goto 100;
  113.        end;
  114.  
  115.     if ZIKeyPressed = #0 + #71 then
  116.        begin
  117.        ptr := 1;
  118.        goto 100;
  119.        end;
  120.  
  121.     if ZIKeyPressed = #0 + #79 then
  122.        begin
  123.        ptr := length(ZIData[CurrentField]) + 1;
  124.        goto 100;
  125.        end;
  126.  
  127.     if ZIKeyPressed = #0 + #82 then
  128.        begin
  129.  
  130.        if length(ZIData[CurrentField]) >= ZILen[CurrentField] then
  131.         begin
  132.         ZBeep(1);
  133.         goto 100;
  134.         end;
  135.  
  136.        if ptr > length(ZIData[CurrentField]) then
  137.         begin
  138.         ZBeep(1);
  139.         goto 100;
  140.         end;
  141.  
  142.  
  143.        if ZIInvalid[CurrentField] = '' then
  144.         Fillchar := ' '
  145.        else
  146.         Fillchar := copy(ZIInvalid[CurrentField], 1, 1);
  147.  
  148.  
  149.        if ptr <> 1 then
  150.         begin
  151.  
  152.         temp := copy(ZIData[Currentfield], 1, ptr - 1);
  153.         tempr := ZRight(ZIData[CurrentField], length (ZIData[currentfield]) - ptr + 1);
  154.         ZIData[CurrentField] := Temp + Fillchar + Tempr;
  155.         end
  156.        else
  157.         ZIData[currentfield] := Fillchar + ZIData[currentfield];
  158.  
  159.  
  160.        gotoxy (ZICol[currentfield], ZIRow[currentfield]);
  161.        Write (ZIData[currentfield]);
  162.        goto 100;
  163.  
  164.  
  165.        end;
  166.  
  167.  
  168.  
  169.     if ZIKeyPressed = #0 + #83 then
  170.         begin
  171.  
  172.         if ptr > length(ZIData[currentfield]) then
  173.             begin
  174.             Zbeep(1);
  175.             goto 100;
  176.             end;
  177.  
  178.         delete(ZIData[currentfield],ptr,1);
  179.         gotoxy (ZICol[currentfield], ZIRow[currentfield]);
  180.         Write (ZIData[currentfield],' ');
  181.         goto 100;
  182.         end;
  183.  
  184.  
  185.     if ZIKeyPressed = #8 then
  186.         begin
  187.  
  188.         if ptr = 1 then
  189.             begin
  190.             Zbeep(1);
  191.             goto 100;
  192.             end;
  193.  
  194.         delete(ZIData[currentfield],ptr-1,1);
  195.         gotoxy (ZICol[currentfield], ZIRow[currentfield]);
  196.         Write (ZIData[currentfield],' ');
  197.         ptr := ptr - 1;
  198.         goto 100;
  199.         end;
  200.  
  201.     if ZIKeyPressed = #0 + #75 then
  202.         if ptr = 1 then
  203.             begin
  204.             Zbeep(1);
  205.             goto 100;
  206.             end
  207.         else
  208.             begin
  209.             ptr := ptr - 1;
  210.             goto 100;
  211.             end;
  212.  
  213.  
  214.     if ZIKeypressed = #0 + #77 then
  215.         if ptr > length(ZIData[currentfield]) then
  216.             begin
  217.             Zbeep(1);
  218.             goto 100;
  219.             end
  220.         else
  221.             begin
  222.             ptr := ptr + 1;
  223.             goto 100;
  224.             end;
  225.  
  226.  
  227.     if copy(ZIKeypressed,1,1) = #0 then exit;
  228.     if ZIKeyPressed = #27 then exit;
  229.  
  230.  
  231.     if ZIInvalid[currentfield] = '' then Checkchars := Validchars
  232.                     else Checkchars := ZIInvalid[currentfield];
  233.  
  234.  
  235.     if pos(ZIKeyPressed, Checkchars) = 0 then
  236.         begin
  237.         ZBeep(1);
  238.         goto 100;
  239.         end;
  240.  
  241.  
  242.     if length(ZIData[currentfield]) >= ZILen[currentfield] then
  243.         if ptr > ZILen[currentfield] then
  244.             begin
  245.             ZBeep(1);
  246.             goto 100;
  247.             end;
  248.  
  249.  
  250.     if ptr > length(ZIData[currentfield]) then
  251.         begin
  252.         ZIData[currentfield] := ZIData[currentfield] + ZIKeyPressed;
  253.         ptr := ptr + 1;
  254.         write(ZIKeyPressed);
  255.         goto 100;
  256.         end
  257.     else
  258.         begin
  259.         delete (ZIKeyPressed, ptr, 1);
  260.         insert (ZIKeypressed, ZIData[currentfield], ptr);
  261.         write (ZIKeyPressed);
  262.         ptr := ptr + 1;
  263.         end;
  264.  
  265.  
  266.  
  267. end;
  268.